package net.yebaihe.wc;

import java.util.ArrayList;
import java.util.HashMap;

import net.yebaihe.wc.DataMan.MSGTYPE;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;

public class IndexSub extends StateMachine{

	@Override
	protected String getTopbarTitle() {
		return "更多";
	}

	@Override
	protected void prepareClient(View client) {
		ListView listview = (ListView) client; 
		ArrayList<HashMap<String, Object>> meumList = new ArrayList<HashMap<String, Object>>(); 

		String idxBtnTitles[]={
			"个人资料",
			"切换城市",
			"意见反馈",
			"关于微餐",
		};
		
		for(int i = 1;i < idxBtnTitles.length+1;i++) { 
			HashMap<String, Object> map = new HashMap<String, Object>(); 
			map.put("title", idxBtnTitles[i-1]); 
			map.put("cnt", ">"); 
			meumList.add(map); 
		} 

		SimpleAdapter saMenuItem = new SimpleAdapter(this, 
				meumList, //数据源 
				R.layout.indexsub_item, //xml实现 
				new String[]{"title","cnt"}, //对应map的Key 
				new int[]{R.id.txtItem,R.id.txtCnt});  //对应R的Id 

		//添加Item到网格中 
		listview.setAdapter(saMenuItem); 
		listview.setOnItemClickListener(new OnItemClickListener() { 
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) { 
				if (arg2==0){
					Intent intent=new Intent(IndexSub.this,UserInfo.class);
					startActivity(intent);
					overridePendingTransition(R.anim.up_in,R.anim.up_out); 
				}
			} 
		} 
				); 
	}

	@Override
	protected void HandleMessage(MSGTYPE register, boolean ret,
			HashMap<String, String> params) {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected int getLayoutRes() {
		return R.layout.indexsub;
	}

}
